import time
from functools import wraps
from inspect import signature


def timethis(func):
    """
    Decorator that reports the execution time.
    :param func:
    :return:
    """
    @wraps(func)
    def wrapper(*args, **kwargs):
        start = time.time()
        result = func(*args, **kwargs)
        end = time.time()
        print('timethis:', func.__name__, end - start)
        return result
    return wrapper


if '__main__' == __name__:

    @timethis
    def countdown(n: int):
        '''
        Counts down
        :param n: number of seconds to count down.
        :return: None
        '''
        while n > 0:
            n -= 1

    print('countdown.__name__', countdown.__name__)
    print('countdown.__doc__', countdown.__doc__)
    print('countdown.__annotations__', countdown.__annotations__)
    print('countdown.__wrapped__', countdown.__wrapped__)
    print('signature(countdown)', signature(countdown))
    print('countdown(1e5)', countdown(1e5))
    print('countdown(1e6)', countdown(1e6))
